package fa.wangxing.leaf.Controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import fa.wangxing.leaf.Service.DishesService;
import fa.wangxing.leaf.pojo.Dishes;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/dishes")
public class DishesController {

    @Resource
    private DishesService dishesService;

    @GetMapping("/getdishes")
    public String getdishes(@RequestParam(required = false,defaultValue = "1") Integer pageIndex , ModelMap modelMap){
        PageInfo<Dishes> dishes = dishesService.getDishes(pageIndex);
        modelMap.put("page", dishes);
        return "dishes";
    }
}
